// 对账增扣项目	
angular
  .module("jgappApp")
  .directive("accountProject", function (openApi, DataService) {
    return {
      scope: {
        data: "=data"
      },
      template:
        '<div class="list table-list" ng-show="data.hasAdRecord==1&&list&&list.length">'+
        '<div class="info-title">对账增扣项目</div>'+
        '<div class="table-item" ng-repeat="item in list">'+
          '<div class="list-item">'+
            '<div class="item-label">款项类型 </div>'+
            '<div class="flow-content" ng-switch="item.adType">'+
              '<div ng-switch-when="1">增项</div>'+
              '<div ng-switch-when="2">扣项</div>'+
            '</div>'+
          '</div>'+
          '<div class="list-item">'+
            '<div class="item-label">项目类别 </div>'+
            '<div class="flow-content">{{item.category }}</div>'+
          '</div>'+
          '<div class="list-item">'+
            '<div class="item-label">增扣金额 </div>'+
            '<div class="flow-content">{{item.adAmount|NBFmt }}</div>'+
          '</div>'+
          '<div class="list-item" ng-show="item.remark">'+
            '<div class="item-label">增扣事由 </div>'+
            '<div class="flow-content">{{item.remark }}</div>'+
          '</div>'+
        '</div>'+
      '</div>',
      replace: true,
      restrict: "AE",
      link: function postLink(scope) {
        scope.$watch("data", function (newvalue) {
          if (newvalue && newvalue.hasAdRecord == 1) {
            DataService.getData(openApi.materialAccount, { id: scope.data.pkId }).then(function (data) {
              scope.list=data
            });
          }
        });
      }
    };
  });
